.TH std::io_errc 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::io_errc \- std::io_errc

.SH Synopsis
   Defined in header <ios>
   enum class io_errc {

       stream = 1,          \fI(since C++11)\fP

   };

   The scoped enumeration std::io_errc defines the error codes reported by I/O streams
   in std::ios_base::failure exception objects. Only one error code
   (std::io_errc::stream) is required, although the implementation may define
   additional error codes. Because the appropriate specialization of
   std::is_error_code_enum is provided, values of type std::io_errc are implicitly
   convertible to std::error_code.

.SH Member constants

   Enumeration constant Value
   stream               1

.SH Non-member functions

   make_error_code(std::io_errc)      constructs an iostream error code
   \fI(C++11)\fP                            \fI(function)\fP
   make_error_condition(std::io_errc) constructs an iostream error condition
   \fI(C++11)\fP                            \fI(function)\fP

.SH Helper classes

   is_error_code_enum<std::io_errc> extends the type trait std::is_error_code_enum to
   \fI(C++11)\fP                          identify iostream error codes
                                    \fI(class template specialization)\fP

.SH Example


// Run this code

 #include <fstream>
 #include <iostream>

 int main()
 {
     std::ifstream f("doesn't exist");
     try
     {
         f.exceptions(f.failbit);
     }
     catch (const std::ios_base::failure& e)
     {
         std::cout << "Caught an ios_base::failure.\\n";
         if (e.code() == std::io_errc::stream)
             std::cout << "The error code is std::io_errc::stream\\n";
     }
 }

.SH Output:

 Caught an ios_base::failure.
 The error code is std::io_errc::stream

.SH See also

   error_code      holds a platform-dependent error code
   \fI(C++11)\fP         \fI(class)\fP
   error_condition holds a portable error code
   \fI(C++11)\fP         \fI(class)\fP
   failure         stream exception
                   \fI(public member class of std::ios_base)\fP
